<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>禅林瑜伽管理端</title>
  <!-- 引入样式 -->
  <link rel="stylesheet" href="../../plugins/element-ui/index.css" />
  <link rel="stylesheet" href="../../styles/common.css" />
  <link rel="stylesheet" href="../../styles/page.css" />
  <style>
    #member-app  .notAdmin::after{
      border: 0 !important;

    }
  </style>
</head>
<body>
  <div class="dashboard-container" id="member-app">
    <div class="container">
      <div class="tableBar">
        <el-input
          v-model="input"
          placeholder="请输入会员姓名"
          style="width: 200px"
          clearable
           @keyup.enter.native="handleQuery"
        >
          <i
            slot="prefix"
            class="el-input__icon el-icon-search"
            style="cursor: pointer"
            @click="handleQuery"
          ></i>
        </el-input>

      </div>
      <el-table
        :data="tableData"
        stripe
        class="tableBox"
      >
        <el-table-column
          prop="name"
          label="操作会员"
          width="120"
        ></el-table-column>


        <el-table-column
        prop="createTime"
        label="操作时间"
        width="150"
      ></el-table-column>

        
        <el-table-column
          prop="operation"
          label="操作类型"
          width="100"
        ></el-table-column>

        <el-table-column
          prop="text"
          label="操作细节"

        ></el-table-column>

<!--        <el-table-column-->
<!--          label="操作"-->
<!--          width="160"-->
<!--          align="center"-->
<!--        >-->
<!--          <template slot-scope="scope">-->
<!--            <el-button-->
<!--              type="text"-->
<!--              size="small"-->
<!--              class="blueBug"-->
<!--              @click="addMemberHandle(scope.row.id)"-->
<!--              :class="{notAdmin:user !== 'admin'}"-->
<!--            >-->
<!--              编辑-->
<!--            </el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <el-pagination
        class="pageList"
        :page-sizes="[10,20,30]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="counts"
        :current-page.sync="page"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      ></el-pagination>
    </div>
  </div>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="../../plugins/vue/vue.js"></script>
    <!-- 引入组件库 -->
    <script src="../../plugins/element-ui/index.js"></script>
    <!-- 引入axios -->
    <script src="../../plugins/axios/axios.min.js"></script>
    <script src="../../js/request.js"></script>
    <script src="../../api/member.js"></script>
    <script>
      new Vue({
        el: '#member-app',
        data() {
          return {
             input: '',
             counts: 0,
             page: 1,
             pageSize: 10,
             tableData : [],
             id : '',
             status : '',
             countCard: 0
          }
        },
        computed: {},

        /*vue初始化挂载函数*/
        created() {

          this.init();

          // alert(1439057691107037185);//js失去精度测试
          if(localStorage.getItem('userInfo')!=null){
            //获取当前登录会员的账号，并赋值给模型数据
            this.user = JSON.parse(localStorage.getItem('userInfo')).username;
          }
        },
        mounted() {
        },
        methods: {
          async init () {
            const params = {
              page: this.page,
              pageSize: this.pageSize,
              name: this.input ? this.input : undefined
            };
            await getMemberlogList(params).then(res => {
              if (String(res.code) === '1') {
                this.tableData = res.data.records || [];
                console.log(this.tableData);

                this.counts = res.data.total
              }
            }).catch(err => {
              this.$message.error('请求出错了：' + err)
            })
          },
          handleQuery() {
            this.page = 1;
            this.init();
          },
           // 添加&修改跳转
          addMemberHandle (st) {
            if (st === 'add'){
              window.parent.menuHandle({
                id: '2',
                url: '/backend/page/member/add.html',
                name: '添加会员'
              },true)
            } else {
              window.parent.menuHandle({
                id: '2',
                url: '/backend/page/member/add.html?id='+st,//跳转到add.html页面并携带一个id参数
                name: '修改会员'
              },true)
            }
          },
          handleSizeChange (val) {
            this.pageSize = val;
            this.init()
          },
          handleCurrentChange (val) {
            this.page = val;
            this.init()
          }
        }
      })
    </script>
</body>
</html>